package com.cyl.order.service.impl;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cyl.order.mapper.TOrderDetailsMapper;
import com.cyl.order.domain.TOrderDetails;
import com.cyl.order.service.ITOrderDetailsService;

/**
 * 订单明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Service
public class TOrderDetailsServiceImpl implements ITOrderDetailsService 
{
    @Autowired
    private TOrderDetailsMapper tOrderDetailsMapper;

    /**
     * 查询订单明细
     * 
     * @param id 订单明细主键
     * @return 订单明细
     */
    @Override
    public TOrderDetails selectTOrderDetailsById(Long id)
    {
        return tOrderDetailsMapper.selectTOrderDetailsById(id);
    }

    /**
     * 查询订单明细列表
     * 
     * @param tOrderDetails 订单明细
     * @return 订单明细
     */
    @Override
    public List<TOrderDetails> selectTOrderDetailsList(TOrderDetails tOrderDetails)
    {
        return tOrderDetailsMapper.selectTOrderDetailsList(tOrderDetails);
    }

    /**
     * 新增订单明细
     * 
     * @param tOrderDetails 订单明细
     * @return 结果
     */
    @Override
    public int insertTOrderDetails(TOrderDetails tOrderDetails)
    {

        LocalDateTime localDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();

        tOrderDetails.setCreateTime(localDateTime);
        return tOrderDetailsMapper.insertTOrderDetails(tOrderDetails);
    }

    /**
     * 修改订单明细
     * 
     * @param tOrderDetails 订单明细
     * @return 结果
     */
    @Override
    public int updateTOrderDetails(TOrderDetails tOrderDetails)
    {
        LocalDateTime localDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();

        tOrderDetails.setUpdateTime(localDateTime);
        return tOrderDetailsMapper.updateTOrderDetails(tOrderDetails);
    }

    /**
     * 批量删除订单明细
     * 
     * @param ids 需要删除的订单明细主键
     * @return 结果
     */
    @Override
    public int deleteTOrderDetailsByIds(Long[] ids)
    {
        return tOrderDetailsMapper.deleteTOrderDetailsByIds(ids);
    }

    /**
     * 删除订单明细信息
     * 
     * @param id 订单明细主键
     * @return 结果
     */
    @Override
    public int deleteTOrderDetailsById(Long id)
    {
        return tOrderDetailsMapper.deleteTOrderDetailsById(id);
    }
}
